unit U_CariKartListesi;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
  cxDataStorage, cxEdit, DB, cxDBData, ADODB, StdCtrls, cxGridLevel,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses,
  cxControls, cxGridCustomView, cxGrid, cxCheckBox, siComp;

type
  TFmCariKartListesi = class(TForm)
    Panel1: TPanel;
    cxgrid1: TcxGrid;
    cxgrid1DBTableView1: TcxGridDBTableView;
    cxgrid1DBTableView1aktif: TcxGridDBColumn;
    cxgrid1DBTableView1carikodu: TcxGridDBColumn;
    cxgrid1DBTableView1firmaadi: TcxGridDBColumn;
    cxgrid1DBTableView1sehir: TcxGridDBColumn;
    cxgrid1DBTableView1temsilcisi: TcxGridDBColumn;
    cxgrid1DBTableView1Tipi: TcxGridDBColumn;
    cxgrid1DBTableView1ozelkod1: TcxGridDBColumn;
    cxgrid1DBTableView1ozelkod2: TcxGridDBColumn;
    cxgrid1DBTableView1kargosu: TcxGridDBColumn;
    cxgrid1DBTableView1kargoodeme: TcxGridDBColumn;
    cxgrid1DBTableView1Guzergahkod: TcxGridDBColumn;
    cxgrid1Level1: TcxGridLevel;
    bKapat: TButton;
    adoCariListesi: TADOQuery;
    DSCariListesi: TDataSource;
    Bsec: TButton;
    procedure bKapatClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure cxgrid1DBTableView1CellClick(Sender: TcxCustomGridTableView;
      ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
      AShift: TShiftState; var AHandled: Boolean);
    procedure cxgrid1DBTableView1DblClick(Sender: TObject);
    procedure cxgrid1DBTableView1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
   C1mode:boolean;
   C2mode:boolean;
   SenderCode1,SenderCode2:string;
  end;

var
  FmCariKartListesi: TFmCariKartListesi;

implementation
     uses u_CariTuruAtama, ana1;
{$R *.dfm}

procedure TFmCariKartListesi.bKapatClick(Sender: TObject);
begin
 Close;
end;

procedure TFmCariKartListesi.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  
  action:=cafree;
  FmCariKartListesi:=nil;

end;

procedure TFmCariKartListesi.FormCreate(Sender: TObject);
begin
  C1mode:=false;
  C2mode:=false;
  adoCariListesi.Close;
  adoCariListesi.open;
  SenderCode1:='';
  SenderCode2:='';
    
end;

procedure TFmCariKartListesi.cxgrid1DBTableView1CellClick(
  Sender: TcxCustomGridTableView;
  ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
  AShift: TShiftState; var AHandled: Boolean);
begin

if c1mode then begin
   if assigned(fmCariTuruAtama) then begin
   fmCariTuruAtama.Kod1:=   adoCariListesi.FieldValues['Carikodu'];
   fmCariTuruAtama.edBCari1.Text:=adoCariListesi.FieldValues['Carikodu'];
   end;
end;

if c2mode then begin
if assigned(fmCariTuruAtama) then begin
   fmCariTuruAtama.Kod2:=adoCariListesi.FieldValues['Carikodu'];
   fmCariTuruAtama.edBCari2.Text:=adoCariListesi.FieldValues['Carikodu'];
end;
end;
end;

procedure TFmCariKartListesi.cxgrid1DBTableView1DblClick(Sender: TObject);
begin
if c1mode then begin
if assigned(fmCariTuruAtama) then begin
   fmCariTuruAtama.Kod1:=adoCariListesi.FieldValues['Carikodu'];
   fmCariTuruAtama.edBCari1.Text:=adoCariListesi.FieldValues['Carikodu'];
   close;
end;
end;

if c2mode then begin
if assigned(fmCariTuruAtama) then begin
   fmCariTuruAtama.Kod2:=adoCariListesi.FieldValues['Carikodu'];
   fmCariTuruAtama.edBCari2.Text:=adoCariListesi.FieldValues['Carikodu'];
   close;
end;
end;
end;

procedure TFmCariKartListesi.cxgrid1DBTableView1KeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
if key=13 then begin
if c1mode then begin
if assigned(fmCariTuruAtama) then begin
   fmCariTuruAtama.Kod1:=adoCariListesi.FieldValues['Carikodu'];
   fmCariTuruAtama.edBCari1.Text:=adoCariListesi.FieldValues['Carikodu'];
   close;
end;
end;

if c2mode then begin
if assigned(fmCariTuruAtama) then begin
   fmCariTuruAtama.Kod2:=adoCariListesi.FieldValues['Carikodu'];
   fmCariTuruAtama.edBCari2.Text:=adoCariListesi.FieldValues['Carikodu'];
   close;
end;
end;
end;
end;

procedure TFmCariKartListesi.FormShow(Sender: TObject);
begin
 if c1mode then begin
 if adoCariListesi.Locate('carikodu',SenderCode1,[]) then begin
 end else begin
    adoCariListesi.First;
 end;
 end;

 if c2mode then begin
 if adoCariListesi.Locate('carikodu',SenderCode2,[]) then begin
 end else begin
    adoCariListesi.First;
 end;
 end;
end;

end.